<template>
  <div class="navbar">
    <van-nav-bar
      :left-text="title"
      right-text="首页"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
  </div>
</template>

<script>
export default {
  name: "navbar",
  data() {
    return {
      title: "",
    };
  },
  props: [],
  components: {},
  computed: {},
  watch: {},
  created() {
    this.title = this.$route.meta.title;
  },
  mounted() {
    //绑定自定义事件
    this.$bus.$on('settitle',this.settitle)
  },
  methods: {
    //  左侧返回按钮
    onClickLeft() {
      this.$router.go(-1);
    },
    //  右侧返回首页按钮
    onClickRight() {
      this.$router.push("/");
    },

    //事件回调
    settitle(val){
      this.title = val
    }
  },
};
</script>

<style scoped>
</style>
